package tree;

import linearlist.Queue;

import java.util.List;
import java.util.PrimitiveIterator;

/**
 * @Author Zhouchb
 * @Create 2021-10-2021/10/27 :20:04
 * @Description
 */
public class BinaryTreeTest {
    public static void main(String[] args) {
        BinaryTree<String, String> binaryTree = new BinaryTree<>();
/*        binaryTree.put("1","林动");
        binaryTree.put("2","萧炎");
        binaryTree.put("3","周元");
        binaryTree.delete("3");
        System.out.println(binaryTree.get("3"));*/
        binaryTree.put("E","5");
        binaryTree.put("B","2");
        binaryTree.put("G","7");
        binaryTree.put("A","1");
        binaryTree.put("D","4");
        binaryTree.put("F","6");
        binaryTree.put("H","8");
        binaryTree.put("C","3");
        binaryTree.put("z","0");
        binaryTree.put("v","0");
        System.out.println("前序遍历");
        List<String> preList = binaryTree.preErgodic();
        int size = preList.size();
        for (String s : preList) {
            System.out.print(s);
            if (--size!=0){
                System.out.print("-");
            }
        }
        System.out.println();
        System.out.println("中序遍历");
        List<String> midList = binaryTree.midErgodic();
        int size2 = midList.size();
        for (String s : midList) {
            System.out.print(s);
            if (--size2!=0){
                System.out.print("-");
            }
        }
        System.out.println();
        System.out.println("后序遍历");
        List<String> afterList = binaryTree.afterErgodic();
        int size3 = afterList.size();
        for (String s : afterList) {
            System.out.print(s);
            if (--size3!=0){
                System.out.print("-");
            }
        }
        System.out.println();
        System.out.println("层序遍历");
        Queue<String> layerErgodic = binaryTree.layerErgodic();
        int size4 = layerErgodic.size();
        for (String s : layerErgodic) {
            System.out.print(s);
            if (--size4!=0){
                System.out.print("-");
            }
        }

        System.out.println();
        System.out.println("树的最大深度");
        int i = binaryTree.maxDepth();
        System.out.println(i);

    }
}
